from .exts import db


class UsersModel(db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True, comment='主键ID')
    username = db.Column(db.String(100), nullable=False, unique=True, comment='用户名')
    password = db.Column(db.String(255), nullable=False, comment='密码')
    salt = db.Column(db.String(100), nullable=False, comment='密码盐')
    avatar = db.Column(db.String(255), nullable=False, comment='头像')
    introduction = db.Column(db.String(255), comment='个性签名')
    roles = db.Column(db.String(255), nullable=False, comment='身份权限')
    name = db.Column(db.String(100), nullable=False, comment='用户名')


class MenusModel(db.Model):
    __tablename__ = 'menus'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True, comment='菜单主键ID')
    parent_id = db.Column(db.Integer, comment='父菜单 id')
    name = db.Column(db.String(100), comment='菜单名称')
    icon = db.Column(db.String(100), comment='icon 图标')
    type = db.Column(db.Integer, comment='类型：1-目录，2-菜单，3-按钮权限，4-外链')
    route_name = db.Column(db.String(100), comment='路由名称')
    path = db.Column(db.String(100), comment='路由地址')
    component = db.Column(db.String(100), comment='组件路径(vue页面完整路径，省略.vue后缀)')
    perm = db.Column(db.String(100), comment='权限标识')
    sort = db.Column(db.Integer, comment='排序（数字越小排名越靠前）')
    redirect = db.Column(db.String(100), comment='跳转路径')
    hidden = db.Column(db.Integer, comment='是否隐藏该路由：1-隐藏，0-显示')
    always_show = db.Column(db.Integer, comment='如果设置为 1，将始终显示根菜单;如果没有设置 alwaysShow，当 item 有多于一个子路由时，它将变成嵌套模式，否则不显示根菜单')
    no_cache = db.Column(db.Integer, comment='如果设置为 1，页面将不会被缓存(默认为 0)')
